<script>
import { mapActions } from 'vuex';

export default {
  async onLaunch() {
    // 初始化应用
    this.setLaunchReady(true);
    this.isAppReadyChange(true);
    
    // 检查本地登录状态
    this.checkLocalLogin();
  },
  methods: {
    ...mapActions(['isAppReadyChange', 'setLaunchReady']),
    
    checkLocalLogin() {
      const isLogin = uni.getStorageSync('isLogin');
      if (!isLogin) {
        // 未登录，跳转到登录页
        uni.reLaunch({
          url: '/pages/login/index'
        });
      } else {
        // 已登录，跳转到聊天页
        uni.reLaunch({
          url: '/pages/chat/index'
        });
      }
    },
  },
};
</script>
